import request from '@/utils/request';

interface NewsItem {
  newsId: string;
  newsTitle: string;
  picUrl: string;
  newsItemContentBind?: string;
}

interface ListResponse {
  list: NewsItem[];
  total: number;
}

export async function qryIndustryNewsListPage(params: {
  pageIndex?: number;
  pageSize?: number;
  param?: {
    newsTitle?: string;
  };
}): Promise<ListResponse> {
  const response = await request('/news/qryIndustryNewsListPage', {
    method: 'POST',
    data: params,
  });
  return {
    list: response.data || [],
    total: response.total || 0,
  };
}

export async function qryIndustryNewsDetail(params: {
  newsId: string;
}): Promise<NewsItem> {
  const response = await request('/news/qryIndustryNewsDetail', {
    method: 'POST',
    data: params,
  });
  return response.data;
}

export async function addIndustryNews(params: {
  newsTitle: string;
  picUrl: string;
  newsItemContentBind: string;
}): Promise<void> {
  await request('/news/addIndustryNews', {
    method: 'POST',
    data: params,
  });
}

export async function updateIndustryNews(params: {
  newsId: string;
  newsTitle: string;
  picUrl: string;
  newsItemContentBind: string;
}): Promise<void> {
  await request('/news/updateIndustryNews', {
    method: 'POST',
    data: params,
  });
}

export async function deleteIndustryNews(params: {
  newsId: string;
}): Promise<void> {
  await request('/news/deleteIndustryNews', {
    method: 'POST',
    data: params,
  });
}